package cn.tedu;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class SimpleMain { public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = new ServerSocket(8888);
    System.out.println("服务已经启动 端口是 8888...");

    while (true) {
        try (Socket socket = serverSocket.accept();
             BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))) {

            String requestLine = reader.readLine();
            System.out.println("Received request: " + requestLine);
            // TODO 还需要做的存储到本地
            writer.write("HTTP/1.1 200 OK\r\n");

            writer.flush();
        } catch (IOException e) {
            System.out.println("Error: " + e.getMessage());
            break;
        }
    }
}


}
